#include <stdio.h>

int main() {
    int N, M, i, j, NUM = 0;
    
    scanf("%d %d", &N, &M);
    int a[N],b[N],count[N];
    for(i = 0; i < N; i++) 
    	count[i] = 1;


    for(i = 0; i < N; i++) 
		scanf("%d %d", &a[i], &b[i]);
	for(i = 0; i < N; i++){
		for(j = a[i]; j <= b[i]; j++)
			count[j] = 0;
	}
	for(i = 1; i <= M; i++)
		if(count[i] == 1){
			NUM++;
		}
			
	printf("%d", NUM);
	return 0;
}